package cn.com.zetatech.loader.entity;

import org.apache.parquet.io.InputFile;
import org.apache.parquet.io.SeekableInputStream;

import java.io.IOException;

/**
 * @author jian.chen@zetatech.com.cn
 * @Description TODO
 * 辅助类：从SeekableInputStream创建InputFile
 * @Date 2024/8/15 16:08
 */
public class InputFileFromSeekableInputStream implements InputFile {
    private final byte[] data;

    public InputFileFromSeekableInputStream(byte[] data) {
        this.data = data;
    }

    @Override
    public long getLength() throws IOException {
        return data.length;
    }

    @Override
    public SeekableInputStream newStream() throws IOException {
        return new SeekableByteArrayInputStream(data);
    }
}